package com.jinmdz.app.dao.dao.provider;


import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * pda冷藏Provider
 *
 * @author Wangshengtao
 * @date 2020-08-24 10:47
 */
public class MournCeremonyProvider {

    /**
     * 按照业务编码查询逝者冷藏信息
     *
     * @param businessCode 业务编码
     * @return
     * @author Wangshengtao
     * @date 2020-08-24 10:51
     */
    public String getMournCeremonyViewByBusinessCode(@Param("businessCode") String businessCode) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" mourn_ceremony.id ");
                builder.append(" , business_code ");
                builder.append(" , mourn_ceremony.hall_type_code ");
                builder.append(" , hall_id ");
                builder.append(" , appointment_in_time ");
                builder.append(" , appointment_out_time ");
                builder.append(" , reality_in_time ");
                builder.append(" , reality_out_time ");
                builder.append(" , process_state_code ");
                builder.append(" , rule_number ");
                builder.append(" , rule_unit ");
                builder.append(" , rule_code ");
                builder.append(" , rule_remark ");
                builder.append(" , mourn_ceremony.remark ");
                builder.append(" , mourn_ceremony.business_type ");
                builder.append(" , random_code ");
                builder.append(" , charge_id ");
                builder.append(" , mourn_ceremony.version ");
                builder.append(" , mourn_ceremony_hall.hall_code ");
                builder.append(" , mourn_ceremony_hall.hall_name ");
                SELECT(builder.toString());
                FROM(" mourn_ceremony ");
                LEFT_OUTER_JOIN(" mourn_ceremony_hall on mourn_ceremony_hall.id = mourn_ceremony.hall_id  ");
                WHERE(" mourn_ceremony.deleted = 0 ");
                WHERE(" business_code=#{businessCode}");
                ORDER_BY(" mourn_ceremony.id desc limit 1 ");
            }
        }.toString();
    }
}
